let docEl = document.documentElement
let setRemTimer = null

function setRem() {
  //设计稿高度1080px
  docEl.style.fontSize = docEl.clientHeight / 1080 + 'px' // rem 随高度变化
  // docEl.style.fontSize = docEl.clientWidth / 1920 + 'px' //rem 随宽度变化
}
setRem()
window.addEventListener(
  'resize',
  function () {
    clearTimeout(setRemTimer)
    setRemTimer = this.setTimeout(function () {
      setRem()
    }, 100)
  },
  false
)
